package com.huiyeji.dynamic.core.bean;

import com.huiyeji.dynamic.core.annotations.DynamicBean;
import com.huiyeji.dynamic.core.annotations.DynamicMethod;

@DynamicBean("boolean")
public class DynamicBoolean {

    @DynamicMethod
    public boolean of(Object value){
        if (value instanceof Boolean){
            return (Boolean)value;
        }

        if (value instanceof String){
            return Boolean.parseBoolean((String)value);
        }

        throw new RuntimeException("参数类型必须为[String]或者[Boolean]");
    }

    @DynamicMethod
    public boolean and(boolean value1,boolean value2){
        return value1 && value2;
    }

    @DynamicMethod
    public boolean or(boolean value1,boolean value2){
        return value1 || value2;
    }
}
